﻿	config.eventcfg = {		
			query_project: function(){
				var self = this;
				var records = self.grid.getSelectionModel().getSelections();
				if (!JxUtil.selectone(records)) return;
				
				var dataId = records[0].get('money_plan__project_id');
				if (dataId.length == 0) {
					alert('暂时没有项目信息！');
					return;
				}
				//过滤条件
				var where_sql = 'project_base.project_id = ?';
				var where_type = 'string';
				var where_value = dataId;
				
				//加载数据
				var hdcall = function(grid) {
					//显示数据
					JxUtil.delay(500, function(){
						Jxstar.loadData(grid, {where_sql:where_sql, where_value:where_value, where_type:where_type});
					});
				};

				//显示数据
				var define = Jxstar.findNode('project_create');
				Jxstar.showData({
					filename: define.gridpage,
					title: define.nodetitle,
					pagetype: 'query',
					nodedefine: define,
					callback: hdcall
				});
			},
			
			query_check1: function() {
				var self = this;
				var records = self.grid.getSelectionModel().getSelections();
				if (!JxUtil.selected(records)) return;
				
				var chkfunid = 'money_plan';
				var is_turn = records[0].get('money_plan__is_turn');
				if (is_turn == '1') chkfunid = 'money_tran';
				this.showWorkFlow(chkfunid, 'check_his');
			},
			
			query_check2: function() {
				var self = this;
				var records = self.grid.getSelectionModel().getSelections();
				if (!JxUtil.selected(records)) return;
				
				var chkfunid = 'money_plan';
				var is_turn = records[0].get('money_plan__is_turn');
				if (is_turn == '1') chkfunid = 'money_tran';
				this.showWorkFlow(chkfunid, 'check_his');
			},
			
			pattach: function() {
				var records = this.grid.getSelectionModel().getSelections();
				if (!JxUtil.selectone(records)) return;
				
				var self = this;
				var keyid = records[0].get('money_plan__plan_id');
				
				var params = 'planid=' + keyid + '&funid=money_query';
				params += '&pagetype=grid&eventcode=pattach';

				//发送请求，取相关附件ID
				Request.postRequest(params, function(data){JxPm.showAttach(data, 'money_query', keyid);});
			}
		};
		
	config.initpage = function(gridNode) {
		var grid = gridNode.page;
		
		JxUtil.delay(1000, function(){
			//如果是厂内人员，则不能看到公司的审批意见
			var userid = JxDefault.getUserId();
			var deptid = JxDefault.getDeptId();
			if (userid.indexOf('admin') < 0 && deptid.substr(0, 4) != '1001') {
				var tool = grid.getTopToolbar();
				var extbtn = JxUtil.getButton(tool, 'ext_menu');
				if (!extbtn) return;
				var ext_menu = extbtn.menu;
				var qry2 = JxUtil.getButton(ext_menu, 'querys2');
				if (qry2) qry2.hide();
			}
		});
		
		var event = gridNode.event;
		event.on('beforecustom', function(ge,code) {
			var records = ge.grid.getSelectionModel().getSelections();
			if (!JxUtil.selectone(records)) return false;
		
			var plan_status = records[0].get('money_plan__plan_status');
			if (plan_status != '91' && code == 'exesql') {
				JxHint.alert('选择的投资计划不是撤销状态，不能恢复！');	
				return false;
			}
			if(plan_status != '42' && code == 'exesql2'){
				JxHint.alert('选择的投资计划不是实施中，不能完成！');	
				return false;
			}
			
		});
	};